#pragma once

#include "FCProperties.h"

namespace UIStone
{
	class FCController_Text : public FCPropertyContainer
		<
			Loki::TL::MakeTypelist
			<
				FCPropertyTextOverflow,
				FCPropertyTextVOverflow,
				FCPropertyTextAlign,
				FCPropertyTextVAlign,
				FCPropertyTextPrefix,
				FCPropertyTextLine,
				FCPropertyTextDirection,
				FCPropertyTextExpandTabs
			>::Result
		>
	{
	public:
		enum TextOverflowType
		{
			TEXT_OVERFLOW_NOCLIP		= 0,
			TEXT_OVERFLOW_CLIP			= 1,
			TEXT_OVERFLOW_WORD_ELLIPSIS	= 2,
			TEXT_OVERFLOW_END_ELLIPSIS	= 3,
			TEXT_OVERFLOW_PATH_ELLIPSIS	= 4
		};

		enum TextVOverflowType
		{
			TEXT_VOVERFLOW_AUTO			= 0,
			TEXT_VOVERFLOW_CLIP			= 1,
		};

		enum TextAlignType
		{
			TEXT_ALIGN_CENTER		= 0,
			TEXT_ALIGN_LEFT			= 1,
			TEXT_ALIGN_RIGHT 		= 2
		};

		enum TextVAlignType
		{
			TEXT_VALIGN_VCENTER		= 0,
			TEXT_VALIGN_TOP			= 1,
			TEXT_VALIGN_BOTTOM 		= 2
		};

		enum TextPrefixType
		{
			TEXT_PREFIX_NOTUSE		= 0,
			TEXT_PREFIX_NORMAL		= 1,
			TEXT_PREFIX_HIDE		= 2,
			TEXT_PREFIX_ONLY		= 3
		};

		enum TextLineType
		{
			TEXT_LINE_AUTO				= 0,
			TEXT_LINE_SINGLE			= 1,
			TEXT_LINE_MULTI_WORD_BREAK	= 2,
			TEXT_LINE_MULTI_CHAR_BREAK	= 3
		};

		enum TextDirectionType
		{
			TEXT_DIRECTION_LEFT_TO_RIGHT= 0,
			TEXT_DIRECTION_RIGHT_TO_LEFT= 1
		};

		enum TextExpandTabsType
		{
			TEXT_EXPAND_TABS_NOTUSE		= 0,
			TEXT_EXPAND_TABS_USE		= 1
		};

		FCController_Text()
		{
			_defaultValue();
		}

		virtual ~FCController_Text() {}

	public:
		UINT GetTextFormat() const
		{
			static int c_arrayOverflow[] = { DT_NOCLIP, 0, DT_WORD_ELLIPSIS, DT_END_ELLIPSIS, DT_PATH_ELLIPSIS } ;
			static int c_arrayVOverflow[] = { 0, DT_EDITCONTROL } ;
			static int c_arrayValign[] = { DT_VCENTER, DT_TOP, DT_BOTTOM } ;
			static int c_arrayAlign[] = { DT_CENTER, DT_LEFT, DT_RIGHT } ;
			static int c_arrayPrefix[] = { DT_NOPREFIX, 0, DT_HIDEPREFIX, DT_PREFIXONLY } ;
			static int c_arrayLine[] = { 0, DT_SINGLELINE, DT_WORDBREAK, DT_WORDBREAK|DT_NOFULLWIDTHCHARBREAK } ;
			static int c_arrayDirection[] = { 0, DT_RTLREADING } ;
			static int c_arrayExpandTabs[] = { 0, DT_EXPANDTABS } ;

			UINT unOverflow = c_arrayOverflow[TextOverflow()];
			UINT unVOverflow= c_arrayVOverflow[TextVOverflow()];
			UINT unVAlign   = c_arrayValign[TextVAlign()];
			UINT unAlign	= c_arrayAlign[TextAlign()];
			UINT unPrefix	= c_arrayPrefix[TextPrefix()];
			UINT unLine		= c_arrayLine[TextLine()];
			UINT unDirect	= c_arrayDirection[TextDirection()];
			UINT unExpandTab= c_arrayExpandTabs[TextExpandTabs()];

			return unOverflow | unVOverflow | unVAlign | unAlign | unPrefix | unLine | unDirect | unExpandTab;
		}

	private:
		void _defaultValue()
		{
			TextOverflow()		=	TEXT_OVERFLOW_CLIP;
			TextVOverflow()		=	TEXT_VOVERFLOW_AUTO;
			TextVAlign()		=	TEXT_ALIGN_CENTER;
			TextAlign()			=	TEXT_VALIGN_VCENTER;
			TextPrefix()		=	TEXT_PREFIX_NOTUSE;
			TextLine()			=	TEXT_LINE_AUTO;
			TextDirection()		=	TEXT_DIRECTION_LEFT_TO_RIGHT;
			TextExpandTabs()	=	TEXT_EXPAND_TABS_NOTUSE;
		}
	};
};